package VN.EDU.IMIC.DEVELOPER.TRINHCAOSANG.BaiTapObject.Exc2;

/**
 * Created by Sang on 23/02/2016.
 */
public class Model {

    public double Cal(Caculator caculator) {
        double relsut = 0;
        switch (caculator.getiOpt()) {
            case 1:
                 relsut = caculator.getNumA() - caculator.getNumB();
                break;
            case 2:
                 relsut = caculator.getNumA() + caculator.getNumB();
                break;
            case 3:
                 relsut = caculator.getNumA() * caculator.getNumB();
                break;
            case 4:
                 relsut = caculator.getNumA() / caculator.getNumB();
                break;
            default:
                break;
        }
        return relsut;

    }

    public boolean CheckZero(Caculator caculator) {
        if (caculator.getiOpt() == 4) {
            if (caculator.getNumA() == 0 && caculator.getNumB() == 0) {
                System.out.println("Result of function is underfined");
            } else if (caculator.getNumA() != 0 && caculator.getNumB() == 0) {
                System.out.println("Cannot divide by zero");
            }
        }
        return true;
    }
}



     /*   public  boolean DivideZero(Caculator caculator){
            if ( caculator.getNumB() == 0 && caculator.getiOpt()== 4){
                System.out.println("Cannot divide by zero");
                return false;
            }else {
                return true;
            }
        }

        public boolean ZerovsZero(Caculator caculator){
            if (caculator.getNumA()== 0 && caculator.getNumB() == 0
                    && caculator.getiOpt()== 4){
                System.out.println("Result of function is underfined");
                return false;
            }else {
                return true;
            }
        }
    */




